﻿using UnityEngine;
using System.Collections;

public class NektarMeter : MonoBehaviour {

	[SerializeField]
	private Transform _meter;
	
	private Vector3 _orgPos;
	private Vector3 _orgScale;
	
	private int _max = 500;
	private int _current = 0;
	
	private float _valScale;
	private float _tmp;
	
	// Use this for initialization
	void Awake()
	{
		_orgPos = _meter.localPosition;
		_orgScale = _meter.localScale;
	}
	
	public void UpdateMeter(int cur, int max)
	{
		_max = max;
		_current = cur;
		_valScale = _orgScale.y / _max;
		_meter.localScale = new Vector3(_orgScale.x, _orgScale.y * ((float)_current/(float)_max), _orgScale.z);
		_tmp = (_orgScale.y - ( _orgScale.y * ((float)_current/(float)_max))) * 0.5f;
		_meter.localPosition = new Vector3(_orgPos.x, _orgPos.y - _tmp, _orgPos.z);
	}
}
